package org.example.springboot.dao;

import org.apache.ibatis.annotations.*;
import org.example.springboot.model.Items;
import org.example.springboot.model.Suppliers;

import java.util.List;
@Mapper
public interface ItemsMapper {
    @Insert("insert into items(project_name, project_leader, contact_phone, sales_team,sales_contact_phone, after_sales_team,after_sales_contact_phone,project_description,cost_description) values(#{projectName},#{projectLeader},#{contactPhone}, #{salesTeam}, #{salesContactPhone},#{afterSalesTeam}, #{afterSalesContactPhone}, #{projectDescription},#{costDescription})")
    int insertItem(@Param("projectName") String projectName, @Param("projectLeader") String projectLeader, @Param("contactPhone") String contactPhone, @Param("salesTeam") String salesTeam, @Param("salesContactPhone") String salesContactPhone, @Param("afterSalesTeam") String afterSalesTeam, @Param("afterSalesContactPhone") String afterSalesContactPhone, @Param("projectDescription") String projectDescription, @Param("costDescription") String costDescription);

    @Select("select * from items")
    List<Items> getAllItems();

    @Select("select * from items " + "where project_name like CONCAT('%', #{keyword}, '%') " + "or project_leader like CONCAT('%', #{keyword}, '%')"+ "or sales_team like CONCAT('%', #{keyword}, '%')"+ "or after_sales_team like CONCAT('%', #{keyword}, '%')")
    List<Items> findItemByKeyword(@Param("keyword")String keyword);

    @Delete("delete from items where id = #{id}")
    void deleteItemById(@Param("id")int id);

    @Select("select * from items where id = #{id}")
    Items findItemById(int id);
}
